---
apiVersion: v1
kind: DeploymentConfig
metadata:
  labels:
    app: fedora-packages-static
    service: fedora-packages-static
  name: fedora-packages-static
spec:
  replicas: 1
  selector:
    app: fedora-packages-static
    deploymentconfig: fedora-packages-static
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: fedora-packages-static
        deploymentconfig: fedora-packages-static
    spec:
      initContainers:
      - name: init-solr
        image: busybox
        command: ['sh', '-c', 'until nslookup solr.fedora-packages-static.svc.cluster.local; do echo waiting for solr; sleep 2; done;']
      containers:
      - name: fedora-packages-static
        image: fedora-packages-static:latest
        env:
        - name: SOLR_URL
          valueFrom:
            configMapKeyRef:
              name: fedora-packages-static-configmap
              key: solr-url
        - name: SITEMAP_URL
          valueFrom:
            configMapKeyRef:
              name: fedora-packages-static-configmap
              key: sitemap-url
        ports:
        - containerPort: 8080
        resources: {}
        volumeMounts:
        - name: data-volume
          mountPath: /srv/packages
        - name: db-volume
          mountPath: /etc/packages
        readinessProbe:
          timeoutSeconds: 5
          initialDelaySeconds: 30
          httpGet:
            path: /
            port: 8080
        livenessProbe:
          timeoutSeconds: 5
          initialDelaySeconds: 30
          httpGet:
            path: /
            port: 8080
      volumes:
      - name: data-volume
        persistentVolumeClaim:
          claimName: fedora-packages-static-storage{{ '-stg' if env == 'staging' else '' }}
      - name: db-volume
        persistentVolumeClaim:
          claimName: fedora-packages-static-db-storage{{ '-stg' if env == 'staging' else '' }}

  triggers:
  - type: ConfigChange
  - type: ImageChange
    imageChangeParams:
      automatic: true
      containerNames:
      - fedora-packages-static
      from:
        kind: ImageStreamTag
        name: fedora-packages-static:latest
---
apiVersion: v1
kind: DeploymentConfig
metadata:
  labels:
    app: fedora-packages-static
    service: solr
  name: solr
spec:
  replicas: 1 # Only 1! Solr is not configured in cloud mode yet.
  selector:
    app: fedora-packages-static
    deploymentconfig: fedora-packages-static
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: fedora-packages-static
        deploymentconfig: fedora-packages-static
    spec:
      containers:
      - name: solr
        image: solr:8
        command:
        - bash
        - /opt/solr-start/solr-start.sh
        ports:
        - containerPort: 8983
        resources: {}
        volumeMounts:
        - name: data-volume
          mountPath: /var/solr
        - name: config-volume
          mountPath: /opt/solr/server/solr/configsets/packages
          readOnly: true
        - name: script-volume
          mountPath: /opt/solr-start
        readinessProbe:
          timeoutSeconds: 1
          initialDelaySeconds: 30
          httpGet:
            path: /
            port: 8983
        livenessProbe:
          timeoutSeconds: 1
          initialDelaySeconds: 40
          httpGet:
            path: /
            port: 8983
      # Add solr's default gid to nfs group
      securityContext:
        supplementalGroups: [8983]
      volumes:
      - name: data-volume
        persistentVolumeClaim:
            claimName: solr-storage{{ '-stg' if env == 'staging' else '' }}
      - name: config-volume
        configMap:
          name: fedora-packages-static-solr-configmap
      - name: script-volume
        configMap:
          name: fedora-packages-static-solr-start-configmap

  triggers:
  - type: ConfigChange
